package com.zjdiepu.www.manage.api.zpp.controller;
import io.swagger.annotations.Api;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.zjdiepu.www.base.BaseController;
import com.zjdiepu.www.base.core.BaseException;
import com.zjdiepu.www.base.enums.type.ResultFlagType;
import com.zjdiepu.www.dao.zpp.VideoMianQianMapper;
import com.zjdiepu.www.dao.zpp.ext.DiepuVideoInterviewListExt;
import com.zjdiepu.www.dao.zpp.ext.DiepuVideoInterviewSecondListExt;
import com.zjdiepu.www.dao.zpp.vo.DiepuVideoInterviewList;
import com.zjdiepu.www.dao.zpp.vo.DiepuVideoInterviewSecondList;
import com.zjdiepu.www.dao.zpp.vo.DiepuVideoInterviewSecondListVo;
import com.zjdiepu.www.util.CommonUtil;

@RestController
@RequestMapping(value= "VideoMianQianController", produces="application/json;charset=UTF-8")
@Api(tags = {"作者：张鹏鹏"}, produces="application/json;charset=UTF-8")
public class VideoMianQianController extends BaseController
{
	@Resource
	private VideoMianQianMapper videoMianQianMapper;
	
	/**
	 * 二次面签列表
	 * @param diepuVideoInterviewListExt
	 * @return
	 */
	@RequestMapping(value="diepuVideoInterviewList",method = RequestMethod.POST, produces="application/json;charset=UTF-8")
	public Map<String, Object> diepuVideoInterviewList(String busiId)
	{
		Map<String, Object> maps = success();
		
		//面签之前的数据
		DiepuVideoInterviewListExt diepuVideoInterviewListExt = new DiepuVideoInterviewListExt();
		diepuVideoInterviewListExt.setBusiId(busiId);
		List<DiepuVideoInterviewList> list = videoMianQianMapper.diepuVideoInterviewList(diepuVideoInterviewListExt);
		diepuVideoInterviewListExt = null;
		
		//面签之后的数据
		DiepuVideoInterviewSecondListExt diepuVideoInterviewSecondListExt = new DiepuVideoInterviewSecondListExt();
		diepuVideoInterviewSecondListExt.setBusiId(busiId);
		List<DiepuVideoInterviewSecondList> list2 = videoMianQianMapper.diepuVideoInterviewSecondList(diepuVideoInterviewSecondListExt);
		diepuVideoInterviewSecondListExt = null;
		
		//对比
		if(null == list || list2 == null)
		{
			throw new BaseException(ResultFlagType.MISSING.getCode(),"当前数据不存在");
		}
		
		//面签前的值
		DiepuVideoInterviewList diepuVideoInterviewList = list.get(0);
		list = null;
		
		//面签后的值
		DiepuVideoInterviewSecondList diepuVideoInterviewSecondList = list2.get(0);
		list2 = null;
		
		DiepuVideoInterviewSecondListVo diepuVideoInterviewSecondListVo  = null;
		
		if(null != diepuVideoInterviewSecondList)
		{
			String amountMonthly = "";
			String loanMonth = "";
			String totalRepaymentAmount = "";
			String signLoanAmount = "";
			String loanAmount = "";
			String servicePrice = "";
			String customerName = "";
			String customerNo = "";
			String carBrand = "";
			String carPrice = "";
			String firstPaymentAmount = "";
			String carModel = "";
			String cxname = "";
			
			
			
			diepuVideoInterviewSecondListVo = new DiepuVideoInterviewSecondListVo();
			
			if(null != diepuVideoInterviewSecondList.getAmountMonthly())
			{
				amountMonthly = CommonUtil.displayWithComma(String.valueOf(diepuVideoInterviewSecondList.getAmountMonthly()));
				diepuVideoInterviewSecondListVo.setAmountMonthly(amountMonthly);
			}
			if(null != diepuVideoInterviewSecondList.getLoanMonth())
			{
				loanMonth = CommonUtil.displayWithComma(String.valueOf(diepuVideoInterviewSecondList.getLoanMonth()));
				diepuVideoInterviewSecondListVo.setLoanMonth(loanMonth);
			}
			if(null != diepuVideoInterviewSecondList.getTotalRepaymentAmount())
			{
				totalRepaymentAmount = CommonUtil.displayWithComma(String.valueOf(diepuVideoInterviewSecondList.getTotalRepaymentAmount()));
				diepuVideoInterviewSecondListVo.setTotalRepaymentAmount(totalRepaymentAmount);
			}
			if(null != diepuVideoInterviewSecondList.getSignLoanAmount())
			{
				signLoanAmount = CommonUtil.displayWithComma(String.valueOf(diepuVideoInterviewSecondList.getSignLoanAmount()));
				diepuVideoInterviewSecondListVo.setSignLoanAmount(signLoanAmount);
			}
			if(null != diepuVideoInterviewSecondList.getLoanAmount())
			{
				loanAmount = CommonUtil.displayWithComma(String.valueOf(diepuVideoInterviewSecondList.getLoanAmount()));
				diepuVideoInterviewSecondListVo.setLoanAmount(loanAmount);
			}
			if(null != diepuVideoInterviewSecondList.getServicePrice())
			{
				servicePrice = CommonUtil.displayWithComma(String.valueOf(diepuVideoInterviewSecondList.getServicePrice()));
				diepuVideoInterviewSecondListVo.setServicePrice(servicePrice);
			}
			if(null != diepuVideoInterviewSecondList.getCustomerName())
			{
				customerName = diepuVideoInterviewSecondList.getCustomerName();
				diepuVideoInterviewSecondListVo.setCustomerName(customerName);
			}
			if(null != diepuVideoInterviewSecondList.getCustomerNo())
			{
				customerNo = diepuVideoInterviewSecondList.getCustomerNo();
				diepuVideoInterviewSecondListVo.setCustomerNo(customerNo);
			}
			if(null != diepuVideoInterviewSecondList.getCarBrand())
			{
				carBrand = diepuVideoInterviewSecondList.getCarBrand();
				diepuVideoInterviewSecondListVo.setCarBrand(carBrand);
			}
			if(null != diepuVideoInterviewSecondList.getCarPrice())
			{
				carPrice = String.valueOf(diepuVideoInterviewSecondList.getCarPrice());
				diepuVideoInterviewSecondListVo.setCarPrice(carPrice);
			}
			if(null != diepuVideoInterviewSecondList.getFirstPaymentAmount())
			{
				firstPaymentAmount = String.valueOf(diepuVideoInterviewSecondList.getFirstPaymentAmount());
				diepuVideoInterviewSecondListVo.setFirstPaymentAmount(firstPaymentAmount);
			}
			if(null != diepuVideoInterviewSecondList.getCarModel())
			{
				carModel = diepuVideoInterviewSecondList.getCarModel();
				diepuVideoInterviewSecondListVo.setCarModel(carModel);
			}
			if(null != diepuVideoInterviewSecondList.getCxname())
			{
				cxname = diepuVideoInterviewSecondList.getCxname();
				diepuVideoInterviewSecondListVo.setCxname(cxname);
			}
			
		}
		maps.put("result", diepuVideoInterviewList);
		maps.put("result2", diepuVideoInterviewSecondListVo);
		return maps;
	}
	
}
